#include "scNet/Server.hpp"
#include <iostream>
#include <cassert>

void test_server_start_stop() {
	scNet::Server server;
	try {
		server.start(8081);
		assert(true);
		server.stop();
	} catch (...) {
		assert(false && "Server start/stop test failed");
	}
}

void test_request_handle() {
	scNet::Server server;
	server.setRequestHandler([](const std::string&) { return "!!!TEST_RESPONSE!!!"; });
	// 另外一个端口来测试请求处理	
	server.start(8082);
	assert(true);

	server.stop();		// 测试完了要关服务器
}

int main(int argc, char const *argv[])
{
	test_server_start_stop();
	test_request_handle();
	// 都运行成功才能有成功提示
	std::cout << "All server pass the test" << std::endl;
	return 0;
}
